import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:myapp/api/Http.dart';
import 'package:myapp/api/Urls.dart';
import 'package:myapp/page/home/HomeChildPageOne.dart';
import 'package:myapp/page/home/HomeChildPageThree.dart';
import 'package:myapp/util/PageUtil.dart';
import 'package:myapp/widget/SearchBarDelegate.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, length: 2);
    //获取推广位
    //获取单品推广列表
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    return Theme(
      data: ThemeData(primaryColor: Colors.blueAccent),
      child: Scaffold(
        appBar: AppBar(
          elevation: 1.0,
          title: TabBar(
              controller: _tabController,
              unselectedLabelColor: Colors.grey,
              indicatorColor: Colors.white,
              tabs: [
                Tab(text: "单品爆款"),
                Tab(text: "巨额优惠"),
              ]),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.search),
              onPressed: () {
                showSearch(context: context, delegate: SearchBarDelegate());
              },
            )
          ],
        ),
        body: TabBarView(controller: _tabController, children: [
          PageOne(),
          PageThree(),
        ]),
      ),
    );
  }
}
